<?
/*----------------------------------------------------------------------
          (C) Bobtail-Bear 2006 	小飞熊新一代下载系统
          	代码编写：小飞熊	版权所有：小飞熊[L.F.Bear]
				官方网站/技术支持：http://www.bobtail-bear.cn
------------------------------------------------------------------------
          (C) Bobtail-Bear 2006 	L.F.Bear's New Download Sysytem
          	Powered by L.F.Bear  Copyright L.F.Bear's Home(R)
               Official Web/Support：http://www.bobtail-bear.cn
-----------------------------------------------------------------------*/

//本页脚本功能：显示分类页面

$thispage="sort.php";
$searchbar="y";
require("header.php"); 
$sub=$_GET[subclass];
$main=$_GET[mainclass];
empty($_GET[page]) ? $now_page=1 : $now_page=$_GET[page];


//调入子分类
if($main && empty($sub))
{
$sc_show="<table width=\"570\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"100\" height=\"30\" align=\"center\" class=\"markedText2\">$p_lang[28]</td><td width=\"470\" class=\"markedText2\">";
$num=0;
unset($subclass_info);
$subclass_info=file("include/subclass.php");
$sc_count=count($subclass_info);
//echo $sc_count;

for($k=0;$k<$sc_count;$k++)
{
unset($sc_temp);
$sc_temp=explode("|",$subclass_info[$k]);
//echo $sc_temp[1];
if($sc_temp[1]==$main) {$num++; if($num%5==0) $sc_show.="<br>"; $sc_show.="&nbsp;[<a href=sort.php?subclass=$sc_temp[0] title=\"$sc_temp[3]\">$sc_temp[2]</a>]&nbsp;";}
}
$sc_show.="</td></tr></table>";
//end
}


//调入软件数据
$now_num=readf($path_soft."/number");
$list_num=ceil($now_num/100);
$list_info=file("cache/soft_list_".$list_num.".php");
$lcount=count($list_info);
//for($i=$lcount-1;$i>=0;$i--)
$i=$lcount-1;
while($i>=0 && !($list_num==1&&$i==-1))
{

$thisone=explode("|",$list_info[$i]);
showclassname($thisone[4],$thisone[5]);
//empty($now_page) ? $now_page=1 : $now_page=$now_page;


if($sub && empty($main)){
if ($thisone[5]==$sub)
{ 
$find_num++;
$page=ceil($find_num/20);
$soft_info[$page].="  <tr>
    <td height=\"25\">&nbsp;<a href=sort.php?mainclass=$thisone[4]>$classname[0]</a>→$classname[1]</td>
    <td><a href=view.php?id=$thisone[0]  target=\"_blank\">$thisone[2]</a></td>
    <td align=\"center\"> $thisone[6] </td>
  </tr>";
}}

elseif($main && empty($sub))
{
if ($thisone[4]==$main)
{ 
$find_num++;
$page=ceil($find_num/20);
$soft_info[$page].="  <tr>
    <td height=\"25\">&nbsp;$classname[0]→<a href=sort.php?subclass=$thisone[5]>$classname[1]</a></td>
    <td><a href=view.php?id=$thisone[0]  target=\"_blank\">$thisone[2]</a></td>
    <td align=\"center\"> $thisone[6] </td>
  </tr>";
}
}
elseif($main && $sub)
{
if ($thisone[4]==$main && $thisone[5]==$sub)
{
$find_num++;
$page=ceil($find_num/20);
$soft_info[$page].="  <tr>
    <td height=\"25\">&nbsp;$classname[0]→$classname[1]</td>
    <td><a href=view.php?id=$thisone[0]  target=\"_blank\">$thisone[2]</a></td>
    <td align=\"center\"> $thisone[6] </td>
  </tr>";
}
}  
else
{
$find_num++;
$page=ceil($find_num/20);
$soft_info[$page].="  <tr>
    <td height=\"25\">&nbsp;<a href=sort.php?mainclass=$thisone[4]>$classname[0]</a>→$classname[1]</td>
    <td><a href=view.php?id=$thisone[0]  target=\"_blank\">$thisone[2]</a></td>
    <td align=\"center\"> $thisone[6] </td>
  </tr>";
}  
$i--;
if($i<0) {$list_num--;$list_info=file("cache/soft_list_".$list_num.".php");
$lcount=count($list_info);$i=$lcount-1;}
}

//调入下载TOP10
$td10_info=@file("cache/top_soft.php");
$td_show="<table width=\"175\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td>";

for($dn=0;$dn<count($td10_info);$dn++)
{
unset($tempy);
$tempy=explode("|",$td10_info[$dn]);
$td_show.="<li><a href=view.php?id=$tempy[0] title=\"$tempy[1]\"> $tempy[1] </a></li>";
}
if(count($td10_info)==0) $td_show.=$p_lang[1];

$td_show.="</td></tr></table>";

//用户登陆
if($users=="n")
{
$div=f_l_list(2);
$skip=1;
}
if($skip!=1 && $_SESSION[f_login]=="yes" && $_COOKIE[l_state]=="ok")
$div=f_l_list(1);
elseif($skip!=1 && ($_SESSION[f_login]!="yes" || $_COOKIE[l_state]!="ok"))
$div=f_l_list(0);

if($now_page>1)  $pageup=$now_page-1; else $pageup="";
if($now_page<$page)  $pagedown=$now_page+1; else $pagedown="";

	require("template.php");
	$pagex = new SmartTemplate( "sort.html" );
	$pagex->assign('div',$div);
	$pagex->assign('td_show',$td_show);
	$pagex->assign('find_num',$find_num);
	$pagex->assign('sc_show',$sc_show);
	$pagex->assign('page',$page);
	$pagex->assign('now_page',$now_page);
	$pagex->assign('soft_info',$soft_info[$now_page]);
	$pagex->assign('main',$main);
	$pagex->assign('sub',$sub);
	$pagex->assign('pageup',$pageup);
	$pagex->assign('pagedown',$pagedown);
	$pagex->assign('imagepath',$imagepath);
	$pagex->assign('t_lang',$t_lang);
	$pagex->output();

require("footer.php");
die(); 
?>